package com.example.testtouch2;

import java.util.ArrayList;
import java.util.List;

import com.demo.androidgame.fx.gl.SpriteBatcher;
import com.demo.androidgame.fx.math.OverlapTester;
import com.demo.androidgame.fx.math.Rectangle;
import com.demo.androidgame.fx.math.Vector2;

public class World {

	public static final float WORLD_WIDTH = 720;
	public static final float WORLD_HEIGHT = 1280;

	static final int FIELD_WIDTH = 10;
	static final int FIELD_HEIGHT = 18;

	static final int X_BOX = (int) (WORLD_WIDTH / FIELD_WIDTH);
	static final int Y_BOX = (int) (WORLD_HEIGHT / FIELD_HEIGHT);

	public static final int PRESNET1_STATE_OVERLEP = 0;
	public static final int PRESNET2_STATE_OVERLEP = 1;
	public static final int PRESNET3_STATE_OVERLEP = 2;
	public static final int PRESNET4_STATE_OVERLEP = 3;
	
	public ArrayList<ArrayList<Rectangle>> fieldRectPa;
	public ArrayList<ArrayList<Rectangle>> colliderBoxs;

	public List<Present> listPresents;
	
	public ArrayList<Rectangle> fieldRectCh;
	public ArrayList<Rectangle> colliderBox;

	public ArrayList<AdvanceBox> advanceBoxs;

	public ArrayList<String> colStirng;
	
	static boolean overlapgift = false;
	//nfc
	static boolean nfcCheck = false;
	public final List<Coin> coins;
	
	public final Player player;
	public final Enemy1 enemy1;
	public final Camel camel, camel2;
//	public final ArrayList<Present> presents;
	
	public final Present present1s;
	public final Present present2s; 
	public final Present present3s; 
	public final Present present4s;
	
	public final List<House> houses;

	public float timer;
	public int score;
	public int point0;	//position 에 point와 구분, nfc 적립
	public int x = 0;
	public int deltastack;
	public int gameLevel = 1;
	public int houselevel = 0;
	float sencingTime, sencingTime2;
	float subX, subY;
	int state, boxInt;
	int minimumTime;
	int colI, colJ;
	SpriteBatcher batcher;
	
	
	String[] highScores;
	String[] splitCollider;
	
	boolean isCollision ;
	boolean levelup ;
	boolean boolen1 ;
	boolean boolen2 ;
	boolean boolen3 ;
	boolean boolen4 ;

	public World(/*WorldListener listener*/) {
		
		isCollision = false;
		levelup = false;
		boolen1 = true;
		boolen2 = true;
		boolen3 = true;
		boolen4 = true;
		
		this.houses = new ArrayList<House>();
//		this.house2s = new ArrayList<House2>();
//		this.house3s = new ArrayList<House3>();
//		this.house4s = new ArrayList<House4>();
		
		this.listPresents = new ArrayList<Present>();
		
		this.coins = new ArrayList<Coin>();

		this.present1s = new Present(2.5f * World.X_BOX, 6.5f * Y_BOX);
		this.present2s = new Present(2.5f * World.X_BOX, 8.5f * Y_BOX);
		this.present3s = new Present(6.5f * World.X_BOX, 2.5f * Y_BOX);
		this.present4s = new Present(8.5f * World.X_BOX, 14.5f * Y_BOX);
	
		this.enemy1 = new Enemy1(-1 * World.X_BOX, 15.5f * World.Y_BOX);
		this.camel = new Camel(11 * World.X_BOX, 9.5f * World.Y_BOX);
		this.camel2 = new Camel(11 * World.X_BOX, 16.5f * World.Y_BOX);
	
		this.player = new Player(5.5f * World.X_BOX, 8.5f * World.Y_BOX);
//		player.bounds.lowerLeft.sub(player.bounds.width/2, player.bounds.height/2);
//		this.listener = listener;
		this.score = 0;
//		this.point0 = 0;
		this.timer = 60;

		advanceBoxs = new ArrayList<AdvanceBox>();
		colliderBoxs = new ArrayList<ArrayList<Rectangle>>();
		colStirng = new ArrayList<String>();
		highScores = new String[37];

		placeStain();

		generate();
		
	}

	private void generate() {
		
		if(nfcCheck == true){
			if(gameLevel == 1){
		coins.add(new Coin(9 * World.X_BOX - 35, 12 * World.Y_BOX - 35));
		coins.add(new Coin(6 * World.X_BOX - 35, 14 * World.Y_BOX - 35));
		coins.add(new Coin(7 * World.X_BOX - 35, 17 * World.Y_BOX - 35));
		coins.add(new Coin(9 * World.X_BOX - 35, 8 * World.Y_BOX - 35));
		coins.add(new Coin(10 * World.X_BOX - 35, 3 * World.Y_BOX - 35));
		coins.add(new Coin(8 * World.X_BOX - 35, 6 * World.Y_BOX - 35));
		coins.add(new Coin(5 * World.X_BOX - 35, 4 * World.Y_BOX - 35));
		coins.add(new Coin(3 * World.X_BOX - 35, 5 * World.Y_BOX - 35));
			}
			if(gameLevel == 2){
		coins.add(new Coin(4 * World.X_BOX - 35, 8 * World.Y_BOX - 35));
		coins.add(new Coin(9 * World.X_BOX - 35, 11 * World.Y_BOX - 35));
		coins.add(new Coin(6 * World.X_BOX - 35, 15 * World.Y_BOX - 35));
		coins.add(new Coin(7 * World.X_BOX - 35, 13 * World.Y_BOX - 35));
		coins.add(new Coin(9 * World.X_BOX - 35, 6 * World.Y_BOX - 35));
		coins.add(new Coin(10 * World.X_BOX - 35, 2 * World.Y_BOX - 35));
		coins.add(new Coin(8 * World.X_BOX - 35, 6 * World.Y_BOX - 35));
		coins.add(new Coin(2 * World.X_BOX - 35, 2 * World.Y_BOX - 35));
		coins.add(new Coin(3 * World.X_BOX - 35, 15 * World.Y_BOX - 35));
			}
			if(gameLevel == 3){
		coins.add(new Coin(1 * World.X_BOX - 35, 7 * World.Y_BOX - 35));
		coins.add(new Coin(9 * World.X_BOX - 35, 11 * World.Y_BOX - 35));
		coins.add(new Coin(6 * World.X_BOX - 35, 15 * World.Y_BOX - 35));
		coins.add(new Coin(2 * World.X_BOX - 35, 13 * World.Y_BOX - 35));
		coins.add(new Coin(9 * World.X_BOX - 35, 6 * World.Y_BOX - 35));
		coins.add(new Coin(10 * World.X_BOX - 35, 2 * World.Y_BOX - 35));
		coins.add(new Coin(8 * World.X_BOX - 35, 6 * World.Y_BOX - 35));
		coins.add(new Coin(2 * World.X_BOX - 35, 2 * World.Y_BOX - 35));
		coins.add(new Coin(3 * World.X_BOX - 35, 15 * World.Y_BOX - 35));
			}
			if(gameLevel == 4){
		coins.add(new Coin(1 * World.X_BOX - 35, 7 * World.Y_BOX - 35));
		coins.add(new Coin(9 * World.X_BOX - 35, 11 * World.Y_BOX - 35));
		coins.add(new Coin(6 * World.X_BOX - 35, 15 * World.Y_BOX - 35));
		coins.add(new Coin(2 * World.X_BOX - 35, 13 * World.Y_BOX - 35));
		coins.add(new Coin(9 * World.X_BOX - 35, 6 * World.Y_BOX - 35));
		coins.add(new Coin(10 * World.X_BOX - 35, 2 * World.Y_BOX - 35));
		coins.add(new Coin(8 * World.X_BOX - 35, 6 * World.Y_BOX - 35));
		coins.add(new Coin(2 * World.X_BOX - 35, 2 * World.Y_BOX - 35));
		coins.add(new Coin(3 * World.X_BOX - 35, 15 * World.Y_BOX - 35));
			}		
			}
		houses.clear();
		if(gameLevel == 1){
			
			houses.add (new House(1.5f * World.X_BOX, 16.5f * World.Y_BOX, World.X_BOX, World.Y_BOX));
			houses.add (new House(9.5f * World.X_BOX, 12.5f * World.Y_BOX, World.X_BOX, World.Y_BOX));
			houses.add (new House(1.5f * World.X_BOX, 0.5f * World.Y_BOX, World.X_BOX, World.Y_BOX));
			houses.add (new House(0.5f * World.X_BOX, 10.5f * World.Y_BOX, World.X_BOX, World.Y_BOX));
			
		} else if(gameLevel == 2){
			
			houses.add(new House(2.5f * World.X_BOX, 16.5f * World.Y_BOX, World.X_BOX, World.Y_BOX));
			houses.add(new House(0.5f * World.X_BOX, 11.5f * World.Y_BOX, World.X_BOX, World.Y_BOX));
			houses.add(new House(7.5f * World.X_BOX, 0.5f * World.Y_BOX, World.X_BOX, World.Y_BOX));
			houses.add(new House(9.5f * World.X_BOX, 14.5f * World.Y_BOX, World.X_BOX, World.Y_BOX));
			
		} else if(gameLevel == 3){
			
			houses.add(new House(0.5f * World.X_BOX, 15.5f * World.Y_BOX, World.X_BOX, World.Y_BOX));
			houses.add(new House(7.5f * World.X_BOX, 0.5f * World.Y_BOX, World.X_BOX, World.Y_BOX));
			houses.add(new House(9.5f * World.X_BOX, 16.5f * World.Y_BOX, World.X_BOX, World.Y_BOX));
			houses.add(new House(0.5f * World.X_BOX, 2.5f * World.Y_BOX, World.X_BOX, World.Y_BOX));
			
		} else if(gameLevel == 4){
			
			houses.add(new House(0.5f * World.X_BOX, 15.5f * World.Y_BOX, World.X_BOX, World.Y_BOX));
			houses.add(new House(3.5f * World.X_BOX, 0.5f * World.Y_BOX, World.X_BOX, World.Y_BOX));
			houses.add(new House(3.5f * World.X_BOX, 16.5f * World.Y_BOX, World.X_BOX, World.Y_BOX));
			houses.add(new House(7.5f * World.X_BOX, 16.5f * World.Y_BOX, World.X_BOX, World.Y_BOX));
			
		}
		
		
//		house2s.add(new House2(2.5f * World.X_BOX, 16.5f * World.Y_BOX, World.X_BOX, World.Y_BOX));
//		house2s.add(new House2(0.5f * World.X_BOX, 11.5f * World.Y_BOX, World.X_BOX, World.Y_BOX));
//		house2s.add(new House2(7.5f * World.X_BOX, 0.5f * World.Y_BOX, World.X_BOX, World.Y_BOX));
//		house2s.add(new House2(9.5f * World.X_BOX, 14.5f * World.Y_BOX, World.X_BOX, World.Y_BOX));
//		
//		house3s.add(new House3(0.5f * World.X_BOX, 15.5f * World.Y_BOX, World.X_BOX, World.Y_BOX));
//		house3s.add(new House3(7.5f * World.X_BOX, 0.5f * World.Y_BOX, World.X_BOX, World.Y_BOX));
//		house3s.add(new House3(9.5f * World.X_BOX, 16.5f * World.Y_BOX, World.X_BOX, World.Y_BOX));
//		house3s.add(new House3(0.5f * World.X_BOX, 2.5f * World.Y_BOX, World.X_BOX, World.Y_BOX));
//		
//		house4s.add(new House4(0.5f * World.X_BOX, 15.5f * World.Y_BOX, World.X_BOX, World.Y_BOX));
//		house4s.add(new House4(3.5f * World.X_BOX, 0.5f * World.Y_BOX, World.X_BOX, World.Y_BOX));
//		house4s.add(new House4(3.5f * World.X_BOX, 16.5f * World.Y_BOX, World.X_BOX, World.Y_BOX));
//		house4s.add(new House4(7.5f * World.X_BOX, 16.5f * World.Y_BOX, World.X_BOX, World.Y_BOX));
	}

	private void placeStain() {

		fieldRectPa = new ArrayList<ArrayList<Rectangle>>();
		fieldRectCh = new ArrayList<Rectangle>();

		for (int j = 0; j < FIELD_HEIGHT - 1; j++) {
			for (int i = 0; i < FIELD_WIDTH - 1; i++) {
				fieldRectCh.add(new Rectangle(X_BOX / 2 + X_BOX * i, Y_BOX / 2+ Y_BOX * j, X_BOX, Y_BOX));
			}
			fieldRectPa.add(fieldRectCh);
		}

		for (int z = 0; z < 4; z++) {

			AdvanceBox advanceBox = new AdvanceBox(0, 0);
			advanceBoxs.add(advanceBox);

		}
		
		for(int i = 0; i <36; i++) {
			colliderBox = new ArrayList<Rectangle>();
            highScores[i] = SettingsColliderIO.highscores[i];
            colStirng.add(highScores[i]); 
            splitCollider = colStirng.get(i).split(",");
            createCollider((Integer.parseInt(splitCollider[0])), Integer.parseInt(splitCollider[1]));
		}
	}

	public void update(float deltaTime, Vector2 start, Vector2 point,	boolean touched, boolean firstSence) {
		
//		Log.d("tag", Float.toString(player.position.x) + "/" + Float.toString(present2s.bounds.lowerLeft.sub(player.bounds.lowerLeft.x/2, 0).x));
		
		updateCoins(deltaTime);
		updatePresents(deltaTime);
		updateEnemy1(deltaTime);
		updateCamel(deltaTime);
		updateBox(deltaTime);
		updatePlayer(deltaTime, start, point, touched, firstSence);
		
		
			
		
		
		if(boolen1 == false && boolen2 == false && boolen3 == false && boolen4 == false ){
			
			levelup = true;
			gameLevel +=1; 
//			score *= timer; 
		}
		checkCollisions();
	}

	private void updatePresents(float deltaTime) {
		
		if(present1s.state == Present.Present_STATE_luggage && boolen1 == true){
			
			present1s.luggage(player.position);
			
		}else if(present1s.state == Present.Present_STATE_REMOVE && boolen1 == true){
			
			present1s.remove();
			score += 10;
			boolen1 = false;
			Assets.SendSound.play(1.0f);
			
		}
		
		if(present2s.state == Present.Present_STATE_luggage&& boolen2 == true){

			present2s.luggage(player.position);
			
			
		} else if(present2s.state == Present.Present_STATE_REMOVE && boolen2 == true){
			
			present2s.remove();
			score += 10;
			boolen2 = false;
			Assets.SendSound.play(1.0f);

			
		} 
		
		if(present3s.state == Present.Present_STATE_luggage && boolen3 == true){

			present3s.luggage(player.position);
			
		} else if(present3s.state == Present.Present_STATE_REMOVE && boolen3 == true){
			
			present3s.remove();
			score += 10;
			boolen3 = false;
			Assets.SendSound.play(1.0f);
		} 
		
		if(present4s.state == Present.Present_STATE_luggage && boolen4 == true){

			present4s.luggage(player.position);
			
		} else if(present4s.state == Present.Present_STATE_REMOVE && boolen4 == true){
			
			present4s.remove();
			score += 10;
			boolen4 = false;
			Assets.SendSound.play(1.0f);

		} 
	
	}

	private void cheakPresentCollison(){
		
		if(OverlapTester.overlapRectangles(player.bounds, present1s.bounds)){
			
			present1s.state = Present.Present_STATE_luggage;

		}else if(present1s.state == Present.Present_STATE_luggage && OverlapTester.overlapRectangles(player.bounds, houses.get(0).bounds)){
			
			present1s.state = Present.Present_STATE_REMOVE;

		}else if(OverlapTester.overlapRectangles(player.bounds, present2s.bounds)){
			
			present2s.state = Present.Present_STATE_luggage;
			
		}else if(present2s.state == Present.Present_STATE_luggage && OverlapTester.overlapRectangles(player.bounds, houses.get(1).bounds)){
			
			present2s.state = Present.Present_STATE_REMOVE;

		} else if(OverlapTester.overlapRectangles(player.bounds, present3s.bounds)){
			
			present3s.state = Present.Present_STATE_luggage;
			
		}else if(present3s.state == Present.Present_STATE_luggage && OverlapTester.overlapRectangles(player.bounds, houses.get(2).bounds)){
			
			present3s.state = Present.Present_STATE_REMOVE;

		} else if(OverlapTester.overlapRectangles(player.bounds, present4s.bounds)){
			
			present4s.state = Present.Present_STATE_luggage;

		}else if(present4s.state == Present.Present_STATE_luggage && OverlapTester.overlapRectangles(player.bounds, houses.get(3).bounds)){
			
			present4s.state = Present.Present_STATE_REMOVE;

		}		
	}

	private void checkEnemy1Collision() {
	   
	        if (OverlapTester.overlapRectangles(enemy1.bounds, player.bounds)) {
	        	try {

	        		Assets.collisionSound.play(1.0f);
					Thread.sleep(500);
					
				} catch (InterruptedException e) {
					e.printStackTrace();
				
				}
	        }
	    }
	
	
	private void updateCoins(float deltaTime) {
	
		if(nfcCheck == true){
		int len = coins.size();
		for (int i = 0; i < len; i++) {
			Coin coin = coins.get(i);
			coin.update(deltaTime);
		}
	}
	}

	private void updatePlayer(float deltaTime, Vector2 start, Vector2 point,	boolean touched, boolean firstSence) {
		
		directionCheaker(deltaTime, start, point, firstSence);

		sencingTime2 += deltaTime;
			
		if (touched && isCollision != true) {
			switch (state) {
			// directionCheaker(start, point);
			case Player.PLAYER_STATE_RIGHT:
				if (player.position.x - point.x < 0 && player.position.x < WORLD_WIDTH) {
					player.velocity.set(500f, 0);
				} else {
					player.velocity.set(0, 0);
//					if (sencingTime2 > 0.3f) {
//						player.position.set(boxInt(player.position));
//						sencingTime2 = 0;
//					}
				}
				break;

			case Player.PLAYER_STATE_LEFT:
				if (player.position.x - point.x > 0 && player.position.x > 0) {
					player.velocity.set(-500f, 0);
				} else {
					player.velocity.set(0, 0);
//					if (sencingTime2 > 0.3f) {
//						player.position.set(boxInt(player.position));
//						sencingTime2 = 0;
//					}
				}
				break;

			case Player.PLAYER_STATE_TOP:
				if (player.position.y - point.y < 0 && player.position.y < 17*Y_BOX) {
					player.velocity.set(0, 500f);
				} else {
					player.velocity.set(0, 0);
//					if (sencingTime2 > 0.3f) {
//						player.position.set(boxInt(player.position));
//						sencingTime2 = 0;
//					}
				}
				break;

			case Player.PLAYER_STATE_BOTTOM:
				if (player.position.y - point.y > 0&& player.position.y >0) {
					player.velocity.set(0, -500f);
				} else {
					player.velocity.set(0, 0);
//					if (sencingTime2 > 0.3f) {
//						player.position.set(boxInt(player.position));
//						sencingTime2 = 0;
//					}
				}
				break;
			}
			player.update(deltaTime);
		}
	}

	private void checkCollisions() {
		// +선물!
		cheakPresentCollison();
		checkCoinCollisions();
		cheakBoxCollision();
		checkEnemy1Collision();
	}

	private void checkCoinCollisions() {
		int len = coins.size();
		for (int i = 0; i < len; i++) {
			Coin coin = coins.get(i);
			if (OverlapTester.overlapRectangles(player.bounds, coin.bounds)) {
				
				coins.remove(coin);
				Assets.coinSound.play(1.0f);
				len = coins.size();

				point0 += Coin.COIN_POINT0;
//				score += Coin.Score_POINT0;
			}
		}
//		int len2 = coins2.size();
//		for(int i = 0; i< len2; i++){
//			Coin2 coin2 = coins2.get(i);
//			if(OverlapTester.overlapRectangles(player.bounds, coin2.bounds)){
//				
//				coins2.remove(coin2);
//				len = coins2.size();
//			}
//		}
//		int len3 = coins3.size();
//		for(int i = 0; i< len3; i++){
//			Coin3 coin3 = coins3.get(i);
//			if(OverlapTester.overlapRectangles(player.bounds, coin3.bounds)){
//				
//				coins3.remove(coin3);
//				len = coins3.size();
//			}
//		}
//		int len4 = coins4.size();
//		for(int i = 0; i< len4; i++){
//			Coin4 coin4 = coins4.get(i);
//			if(OverlapTester.overlapRectangles(player.bounds, coin4.bounds)){
//				
//				coins4.remove(coin4);
//				len = coins4.size();
//			}
//		}
		}

	private void directionCheaker(float deltaTime, Vector2 start,	Vector2 point, boolean firstSence) {

		float stepsubsub;

		if (firstSence) {

			subX = point.x - start.x;
			subY = point.y - start.y;
			stepsubsub = Math.abs(subX) - Math.abs(subY);

			if (stepsubsub > 0) {
				if (subX > 0 && player.position.x <  WORLD_WIDTH) {
					state = Player.PLAYER_STATE_RIGHT;
				} else if(subX < 0 && player.position.x > 0){
					state = Player.PLAYER_STATE_LEFT;
				}
			} else if (stepsubsub < 0 ) {
				if (subY > 0 && player.position.y < 17 * Y_BOX) {
					state = Player.PLAYER_STATE_TOP;
				} else if (subY < 0 && player.position.y > 0) {
					state = Player.PLAYER_STATE_BOTTOM;
				}
			} else
				state = Player.PLAYER_STATE_STOP;

			sencingTime = 0;
		}
	}

	public static Vector2 boxInt(Vector2 point) {
		int BDx = 0, BDy = 0;
		Vector2 result = new Vector2();

		for (int j = 0; j < FIELD_HEIGHT; j++) {
			for (int k = 0; k < FIELD_WIDTH; k++) {
				if (point.x > X_BOX * k && point.x <= X_BOX * (k + 1)) {
					BDx = k;
					break;
				}
			}
			if (point.y > Y_BOX * j && point.y <= Y_BOX * (j + 1)) {
				BDy = j;
				result.set(BDx * X_BOX + X_BOX / 2, BDy * Y_BOX + Y_BOX / 2);
				break;
			}
		}
		return result;
	}

	public static Vector2 boxInt(int X, int Y) {
		int BDx = 0, BDy = 0;
		Vector2 result = new Vector2();

		for (int j = 0; j < FIELD_HEIGHT; j++) {
			for (int k = 0; k < FIELD_WIDTH; k++) {
				if (X * X_BOX > X_BOX * k && X * X_BOX <= X_BOX * (k + 1)) {
					BDx = k;
					break;
				}
			}
			if (Y * Y_BOX > Y_BOX * j && Y * Y_BOX <= Y_BOX * (j + 1)) {
				BDy = j;
				result.set(BDx * X_BOX + X_BOX / 2, BDy * Y_BOX + Y_BOX / 2);
				break;
			}
		}
		return result;
	}

	private void createCollider(int i, int j) {

		 colliderBox = new ArrayList<Rectangle>();
		
		 colliderBox.add(new Rectangle(i * X_BOX + X_BOX/2, j * Y_BOX +  Y_BOX/2, X_BOX/5*4, Y_BOX/5*4));
		
		 colliderBoxs.add(colliderBox);

	}

	private void updateEnemy1(float deltaTime) {

		enemy1.regular();
		enemy1.update(deltaTime);

	}
	private void updateCamel(float deltaTime) {
		
		camel.regular();
		camel.update(deltaTime);
		camel2.regular();
		camel2.update(deltaTime);
	}
	private void updateTimer(float deltaTime) {

		timer -= deltaTime;

		// timer -= Timer.TIMER_SCORE;

	}

	private void updateBox(float deltaTime) {

		int len = advanceBoxs.size();
		for (int i = 0; i < len; i++) {
			AdvanceBox adBox = advanceBoxs.get(i);
			adBox.update(deltaTime);
		}
	}

	private void cheakBoxCollision() {

			for (int i = 0; i < 36; i++) {
				
				if (OverlapTester.overlapRectangles(colliderBoxs.get(i).get(0),	player.bounds)) {

					if (player.velocity.x > 0	&& player.bounds.lowerLeft.y	- colliderBoxs.get(i).get(0).lowerLeft.y< Math.abs(1) && player.bounds.lowerLeft.x	- colliderBoxs.get(i).get(0).lowerLeft.x - 20< 0) {
						
						player.velocity.set(0, 0);
						isCollision = true;
						
					}

					if (player.velocity.x < 0	&& player.bounds.lowerLeft.y- colliderBoxs.get(i).get(0).lowerLeft.y < Math.abs(1) && player.bounds.lowerLeft.x- colliderBoxs.get(i).get(0).lowerLeft.x > 0 ) {

						player.velocity.set(0, 0);
						isCollision = true;
						
					}

					if (player.velocity.y > 0	&& player.bounds.lowerLeft.x-colliderBoxs.get(i).get(0).lowerLeft.x < Math.abs(1) && player.bounds.lowerLeft.y- colliderBoxs.get(i).get(0).lowerLeft.y < 0) {

						player.velocity.set(0, 0);
						isCollision = true;
						
					}

					if (player.velocity.y < 0 && player.bounds.lowerLeft.x-colliderBoxs.get(i).get(0).lowerLeft.x < Math.abs(1) && player.bounds.lowerLeft.y- colliderBoxs.get(i).get(0).lowerLeft.y > 0) {


						player.velocity.set(0, 0);
						isCollision = true;
						
					}
				}
			}
		}
	}

